package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmCartoonMapper;
import cn.mcartoon.pojo.MmCartoon;
import cn.mcartoon.service.MmCartoonService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmCartoonServiceImpl implements MmCartoonService {

    @Autowired
    private MmCartoonMapper mmCartoonMapper;

    public MmCartoon getMmCartoonById(Long id){
        return mmCartoonMapper.getMmCartoonById(id);
    }

    public List<MmCartoon>	getMmCartoonListByMap(Map<String,Object> param){
        return mmCartoonMapper.getMmCartoonListByMap(param);
    }

    public Integer getMmCartoonCountByMap(Map<String,Object> param){
        return mmCartoonMapper.getMmCartoonCountByMap(param);
    }

    public Integer insertMmCartoon(MmCartoon mmCartoon){
            return mmCartoonMapper.insertMmCartoon(mmCartoon);
    }

    public Integer updateMmCartoon(MmCartoon mmCartoon){
        return mmCartoonMapper.updateMmCartoon(mmCartoon);
    }

    public Integer deleteMmCartoonById(Long id){
        return mmCartoonMapper.deleteMmCartoonById(id);
    }

    public Integer batchDeleteMmCartoon(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmCartoonMapper.batchDeleteMmCartoon(param);
    }

    public Page<MmCartoon> queryMmCartoonPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmCartoonMapper.getMmCartoonCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmCartoon> mmCartoonList = mmCartoonMapper.getMmCartoonListByMap(param);
        page.setList(mmCartoonList);
        return page;
     }


}
